package view;

/**
 * @ Authors:
 * 
 * @Veronique De Laet
 * @Johan Willems
 * @Pierre Delaere
 * 
 * @version 2011
 */
import java.awt.EventQueue;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import controller.InschrijvingController;
import controller.DataEntity;
import model.Opleiding;


public class InschrijvingsFrame extends javax.swing.JFrame {
	private JButton ButtonRegistreer;
	private JTextField TextBoxCursist;
	private JTextField TextBoxCursus;
	private JComboBox ComboboxCursus;
	private JTextField TextBoxTitelOutput;
	private JTextPane TextBoxOutput;
	private JComboBox ComboboxOpleiding;
	private JTextField TextBoxOpleiding;
	private JTextField TextBoxSchooljaar;
	private JComboBox ComboboxSchooljaar;
	private JTextField TextBoxTitel;
	private JComboBox ComboboxCursisten;
	
	private InschrijvingController inschrijvingController;


	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					InschrijvingsFrame frame = new InschrijvingsFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	
	public InschrijvingsFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setBackground(new java.awt.Color(255,128,0));
			this.setTitle("INSCHRIJVINGSFRAME");
			this.setFont(new java.awt.Font("Arial",1,10));
			{
				ButtonRegistreer = new JButton();
				ButtonRegistreer.setText("Registreer");
				ButtonRegistreer.setFont(new java.awt.Font("Segoe UI",1,15));
				ButtonRegistreer.setBackground(new java.awt.Color(255,0,0));
				ButtonRegistreer.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			}
			{
				ComboBoxModel bxSchooljaarModel = 
						new DefaultComboBoxModel(
								new String[] { "2010-2011","2011-2012", "2012-2013", "2013-2014" });
				ComboboxSchooljaar = new JComboBox();
				ComboboxSchooljaar.setModel(bxSchooljaarModel);
			}
			{
				TextBoxOutput = new JTextPane();
				TextBoxOutput.setBackground(new java.awt.Color(215,215,215));
			}
			{
				TextBoxTitelOutput = new JTextField();
				TextBoxTitelOutput.setText("Geregistreerd:");
				TextBoxTitelOutput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
				TextBoxTitelOutput.setBackground(new java.awt.Color(255,128,0));
				TextBoxTitelOutput.setFont(new java.awt.Font("Segoe UI",1,15));
			}
			{
				TextBoxOpleiding = new JTextField();
				TextBoxOpleiding.setText("Opleiding");
				TextBoxOpleiding.setBackground(new java.awt.Color(255,128,0));
				TextBoxOpleiding.setFont(new java.awt.Font("Segoe UI",1,15));
				TextBoxOpleiding.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			}
			{
				ComboBoxModel CmbOpleidingModel = 
						new DefaultComboBoxModel(
								new String[] { "Selecteer een Opleiding"});
				ComboboxOpleiding = new JComboBox();
				ComboboxOpleiding.setModel(CmbOpleidingModel);
			}
			{
				TextBoxSchooljaar = new JTextField();
				TextBoxSchooljaar.setText("Schooljaar");
				TextBoxSchooljaar.setBackground(new java.awt.Color(255,128,0));
				TextBoxSchooljaar.setFont(new java.awt.Font("Segoe UI",1,15));
				TextBoxSchooljaar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			}
			{
				ComboBoxModel CbxCursusModel = 
						new DefaultComboBoxModel(
								new String[] { "Selecteer een Cursus"});
				ComboboxCursus = new JComboBox();
				ComboboxCursus.setModel(CbxCursusModel);
			}
			{
				TextBoxTitel = new JTextField();
				TextBoxTitel.setText("InschrijvingsFrame");
				TextBoxTitel.setFont(new java.awt.Font("Verdana",1,20));
				TextBoxTitel.setBackground(new java.awt.Color(255,128,0));
				TextBoxTitel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			}
			{
				TextBoxCursus = new JTextField();
				TextBoxCursus.setText("Cursus");
				TextBoxCursus.setBackground(new java.awt.Color(255,128,0));
				TextBoxCursus.setFont(new java.awt.Font("Segoe UI",1,15));
				TextBoxCursus.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			}
			{
				ComboBoxModel CbxCursistenModel = new DefaultComboBoxModel(new String[] { "Selecteer een Cursist"});
				ComboboxCursisten = new JComboBox();
				ComboboxCursisten.setModel(CbxCursistenModel);
			}
			{
				TextBoxCursist = new JTextField();
				TextBoxCursist.setText("Cursist");
				TextBoxCursist.setBackground(new java.awt.Color(255,128,0));
				TextBoxCursist.setFont(new java.awt.Font("Segoe UI",1,15));
				TextBoxCursist.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			}
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap()
				.addComponent(TextBoxTitel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addGap(38)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(ComboboxSchooljaar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(TextBoxSchooljaar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGap(51)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(ComboboxCursisten, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(TextBoxCursist, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGap(50)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(ComboboxCursus, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(TextBoxCursus, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(TextBoxOpleiding, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(ComboboxOpleiding, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGap(23)
				.addComponent(ButtonRegistreer, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
				.addGap(26)
				.addComponent(TextBoxOutput, GroupLayout.PREFERRED_SIZE, 230, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(21, Short.MAX_VALUE));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addContainerGap()
				.addGroup(thisLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(TextBoxOpleiding, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE)
				        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				        .addGroup(thisLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                .addComponent(ComboboxOpleiding, GroupLayout.PREFERRED_SIZE, 278, GroupLayout.PREFERRED_SIZE)
				                .addGap(0, 473, Short.MAX_VALUE))
				            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                .addGap(146)
				                .addComponent(TextBoxCursist, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
				                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				                .addGroup(thisLayout.createParallelGroup()
				                    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                        .addComponent(ComboboxCursisten, GroupLayout.PREFERRED_SIZE, 278, GroupLayout.PREFERRED_SIZE)
				                        .addGap(0, 264, Short.MAX_VALUE))
				                    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                        .addComponent(TextBoxTitel, GroupLayout.PREFERRED_SIZE, 228, GroupLayout.PREFERRED_SIZE)
				                        .addGap(0, 314, Short.MAX_VALUE))
				                    .addGroup(thisLayout.createSequentialGroup()
				                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				                        .addGroup(thisLayout.createParallelGroup()
				                            .addGroup(thisLayout.createSequentialGroup()
				                                .addGap(0, 0, Short.MAX_VALUE)
				                                .addComponent(ButtonRegistreer, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))
				                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                                .addGap(0, 25, Short.MAX_VALUE)
				                                .addComponent(TextBoxSchooljaar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                                .addGap(18)))
				                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				                        .addGroup(thisLayout.createParallelGroup()
				                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                                .addComponent(TextBoxCursus, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE)
				                                .addComponent(ComboboxCursus, GroupLayout.PREFERRED_SIZE, 362, GroupLayout.PREFERRED_SIZE))
				                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                                .addComponent(ComboboxSchooljaar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                                .addGap(328))))))))
				    .addComponent(TextBoxOutput, GroupLayout.Alignment.LEADING, 0, 835, Short.MAX_VALUE))
				.addContainerGap());
			pack();
			this.setSize(877, 655);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
		
		
	}
	
	
	private void ComboboxCursisten_SelectedItemChanged()
	{
		if (ComboboxCursisten.getSelectedItem() != null)
		{
			loadComboboxCursisten();
					
		}
		
	}
	
	private void ComboboxCursussen_SelectedItemChanged()
	{
		if (ComboboxOpleiding.getSelectedItem() != null)
		{
			loadComboboxCursussen();
					
		}
		
	}
	
	
	private void ComboboxOpleidingen_SelectedItemChanged()
	{
		if (ComboboxCursisten.getSelectedItem() != null)
		{
			loadComboboxOpleiding();
					
		}
		
	}
	
	
	private Object [] loadComboboxOpleiding ()
	{ 
		//ArrayList <DataEntity>opleiding = Opleiding;
		ArrayList <DataEntity> data= new ArrayList<DataEntity>();
		
		return data.toArray();
	}	
	
	private Object [] loadComboboxCursussen()
	{
	ArrayList <DataEntity> kursus =inschrijvingController.toonLijstCursussen();
	ArrayList<DataEntity> data= new ArrayList<DataEntity>();
			
		return data.toArray();
	}
	
		
	private Object [] loadComboboxCursisten()
	{
		ArrayList<DataEntity> student=this.inschrijvingController.toonLijstCursisten();
		ArrayList<DataEntity> data= new ArrayList<DataEntity>();
 		
		
		return data.toArray();
		
	}
	
	
}
